#ifndef __LOG_H__
#define __LOG_H__

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdarg>
#include <unistd.h>
#include <cstdarg>
#include <sys/stat.h>
#include <sys/types.h>

#include <log4cxx/logger.h>
#include <log4cxx/patternlayout.h>
#include <log4cxx/consoleappender.h>
#include <log4cxx/dailyrollingfileappender.h>

#include "qSingleton.h"



#define MSG_LEN 4096 
class qLogger
{
public:
	qLogger(std::string& filename);
	~qLogger();

	void setName(const std::string& filename);

	void addConsoleLog();
	void removeConsoleLog();
	void addLocalFileLog(const std::string& file);
	void removeLocalFileLog(const std::string& file);

	//void getMessage(const char* pattern);
	void info(const char* pattern, ...);
	void log(const char* pattern, ...);
	void debug(const char* pattern, ...);
	void warn(const char* pattern, ...);
	void error(const char* pattern, ...);
private:
	std::string local_logname_;//��־�ļ�λ��

	log4cxx::LoggerPtr logger_;
	char message_[MSG_LEN];

	qMutex mt_;
};


#define LOG_FFL __FUNCTION__,__FILE__,__LINE__
#define LOG_INFO logger->info
#define LOG_DEBUG logger->debug
#define LOG_WARN logger->warn
#define LOG_ERROR logger->error 

extern qLogger* logger;

#endif
